#include <iostream>
using namespace std;

const int MAXIMUM_SIZE = 100; // Maximum string size 100

class MyString1
{
public:
  MyString1()
  {
    size = 0;
  }

  MyString1(char * chars)
  {
    int i = 0;
    for (; chars[i] != '\0'; i++)
      value[i] = chars[i];

    size = i;
  }

  MyString1(char ch, int n)
  {
    for (int i = 0; i < n; i++)
      value[i] = ch;

    size = n;
  }

  MyString1(char chars[], int size)
  {
    for (int i = 0; i < size; i++)
      value[i] = chars[i];

    this->size = size;
  }

  MyString1 append(MyString1 s)
  {
    for (int i = 0; i < s.length(); i++)
      value[size + i] = s.at(i);

    size += s.length();

    return MyString1(value, size);
  }

  MyString1 append(MyString1 s, int index, int n)
  {
    for (int i = 0; i < s.length() && i < n; i++)
      value[size + i] = s.at(index + i);

    size += s.length();

    return MyString1(value, size);
  }

  MyString1 append(int n, char ch)
  {
    for (int i = size; i < size + n; i++)
      value[i] = ch;

    size += n;

    return MyString1(value, size);
  }

  MyString1 assign(char chars[])
  {
    int i;
    for (i = 0; chars[i] != '\0'; i++)
      value[i] = chars[i];

    size = i;

    return MyString1(value, size);
  }

  MyString1 assign(MyString1 s, int index, int n)
  {
    int i;
    for (i = 0; i < n; i++)
      value[i] = s.at(index + i);

    size = n;

    return MyString1(value, size);
  }

  MyString1 assign(MyString1 s, int n)
  {
    return assign(s, 0, n);
  }

  MyString1 assign(int n, char ch)
  {
    for (int i = 0; i < n; i++)
      value[i] = ch;

    size = n;

    return MyString1(value, size);
  }

  char at(int index)
  {
    return value[index];
  }

  int length()
  {
    return size;
  }

  void clear()
  {
    size = 0;
  }

  MyString1 erase(int index, int n)
  {
    char temp[MAXIMUM_SIZE];
    for (int i = 0; i < size && i < index; i++)
      temp[i] = value[i];

    return MyString1(temp, size - n);
  }

  bool empty()
  {
    return size == 0;
  }

  int compare(MyString1 s)
  {
    return compare(0, size, s);
  }

  int compare(int index, int n, MyString1 s)
  {
    char * s1 = data();
    char * s2 = s.data();

    return strcmp(s1, s2);
  }

  void copy(char s[], int index, int n)
  {
    int i = 0;
    for (; i < size && i < n; i++)
      s[i] = value[i + index];

    i = i + 1;
    s[i] = '\0';
  }

  char * data()
  {
    char * temp = new char[size + 1];
    for (int i = 0; i < size; i++)
      temp[i] = value[i];

    temp[size] = '\0';

    return temp;
  }

  MyString1 substr(int index, int n)
  {
    char * temp = new char[n];
    for (int i = 0; i < size && i < n; i++)
      temp[i] = value[i + index];

    return MyString1(temp, n);
  }

  MyString1 substr(int index)
  {
    return substr(index, size - index - 1);
  }

  void swap(MyString1 s)
  {
    char * temp = s.data();
    int tempSize = s.length();

    s.assign(value);

    // Copy temp to value
    for (int i = 0; i < tempSize; i++)
      value[i] = temp[i];
    size = tempSize;
  }

  int find(char ch)
  {
    return find(ch, 0);
  }

  int find(char ch, int index)
  {
    for (int i = index; i < size; i++)
      if (value[i] == ch) return i;

    return -1;
  }

  int find(MyString1 s, int index)
  {
    return -1;
  }

private:
  char value[MAXIMUM_SIZE];
  int size;
}; // Must place a semicolon here


int main()
{
  char s[] = {'a', 'b', 'c'};
  MyString1 stringObject1(s, 3);
  MyString1 stringObject2(s, 3);

  stringObject1.append(stringObject2);

  for (int i = 0; i < stringObject1.length(); i++)
  {
    cout << stringObject1.at(i);
  }

  cout << endl;


  cout << stringObject1.compare(stringObject2) << endl;

  string s1 = "abv";
  string s2 = "edf";
  cout << (s1 + s2) << endl;

  return 0;
}


